package com.adams.sys.security;

import org.springframework.security.context.SecurityContextHolder;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.adams.access.db.bean.User;
import com.adams.security.dao.VASUser;
@Transactional
public class UserDetailsService {
	@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
	public static User getUser(){
		VASUser userDetails = (VASUser) SecurityContextHolder.getContext().
	    	getAuthentication().getPrincipal();
		if (userDetails == null)
		{
			throw new RuntimeException("你的访问已超时，请退出重新登录");
		} else{
			return userDetails.getUser();
		}
	}

}
